package com.coderising.jvm;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import org.apache.commons.io.IOUtils;

public class ClassFileLoader extends ClassLoader{
	
	 static String classpath;
	
	
	
	public String getClasspath() {
		return classpath;
	}



	public static void setClasspath(String classpath) {
		ClassFileLoader.classpath = classpath;
	}



	public static byte[] loadClassFile(String classFileName){
		
		classFileName=classFileName.replace('.',File.separatorChar)+".class";
		System.out.println(classFileName);
		try {
			return IOUtils.toByteArray(new FileInputStream(new File(classpath+File.separatorChar+classFileName)));
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	
}
